//
//  ViewController.m
//  26-HomeWork
//
//  Created by 鹏飞罗 on 16/8/18.
//  Copyright © 2016年 罗鹏飞. All rights reserved.
//

#import "ViewController.h"
#import "Masonry.h"
@interface ViewController ()
@property (nonatomic,strong) UIImageView *myImageView;
@property (nonatomic,strong) UILabel *singerLable;
@property (nonatomic, strong) UIButton *twoButton;
@property (nonatomic,strong) UIImageView *jielunImageView;
@property (nonatomic, strong) UIPageControl *pageController;
@property (nonatomic, strong) UISlider *mySlider;
@property (nonatomic, strong) UIButton *playButton;
@property (nonatomic, strong) UIButton *downLoadButton;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //背景图片
    self.myImageView = [[UIImageView alloc] init];
    self.myImageView.image = [UIImage imageNamed:@"welcome_2"];
    [self.view addSubview:self.myImageView];
    [self.myImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    [self createTitle];
    [self createThreeButton];
    [self createJieLunImageView];
   [self createPageControll];
    [self createSlider];
    [self createPlayButton];
    [self createBottomButton];
    
}
- (void) createTitle {
    UILabel *musicLable = [[UILabel alloc] init];
    musicLable.text = @"稻香";
    musicLable.textColor = [UIColor whiteColor];
    musicLable.font = [UIFont systemFontOfSize:20];
    musicLable.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:musicLable];
    [musicLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.centerX.mas_equalTo(0);
        make.height.equalTo(self.view.mas_height).multipliedBy(0.08);
    }];
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    leftButton.backgroundColor = [UIColor whiteColor];
    [leftButton setImage:[UIImage imageNamed:@"player_btn_putDown"] forState:UIControlStateNormal];
    [self.view addSubview:leftButton];
    [leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(musicLable.mas_centerY);
        make.left.mas_equalTo(0);
        make.width.height.mas_equalTo(musicLable.mas_height);
    }];
    UIButton *threeButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    threeButton.backgroundColor = [UIColor whiteColor];
    [threeButton setImage:[UIImage imageNamed:@"player_btn_threeRound dot"] forState:UIControlStateNormal];
    [self.view addSubview:threeButton];
    [threeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(musicLable.mas_centerY);
        make.right.mas_equalTo(0);
        make.width.height.mas_equalTo(musicLable.mas_height);            }];
    _singerLable= [[UILabel alloc] init];
    _singerLable.text = @"--周杰伦--";
    _singerLable.textColor = [UIColor whiteColor];
    _singerLable.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:_singerLable];
//    singerLabel.backgroundColor = [UIColor whiteColor];
    [_singerLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(musicLable.mas_bottom);
        make.height.mas_equalTo(self.view.mas_height).multipliedBy(0.06);
    }];
}
- (void) createThreeButton {
    
   _twoButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_twoButton setImage:[UIImage imageNamed:@"player_btn_mv"] forState:UIControlStateNormal];
    [self.view addSubview:_twoButton];
    [_twoButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(_singerLable.mas_bottom);
        make.height.mas_equalTo(_singerLable.mas_height);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.2);
    }];
    UIButton *oneButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [oneButton setImage:[UIImage imageNamed:@"player_btn_normal"] forState:UIControlStateNormal];
    [self.view addSubview:oneButton];
    [oneButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_twoButton.mas_centerY);
        make.width.mas_equalTo(_twoButton.mas_width);
        make.height.mas_equalTo(_twoButton.mas_height);
        make.trailing.mas_equalTo(_twoButton.mas_leading);
    }];
    UIButton *threeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [threeButton setImage:[UIImage imageNamed:@"player_btn_dts_on"] forState:UIControlStateNormal];
    [self.view addSubview:threeButton];
    [threeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_twoButton.mas_centerY);
        make.width.mas_equalTo(_twoButton.mas_width);
        make.height.mas_equalTo(_twoButton.mas_height);
        make.leading.mas_equalTo(_twoButton.mas_trailing);
    }];
}
- (void) createJieLunImageView {
    UIView *jielunLable = [[UIView alloc] init];
    jielunLable.userInteractionEnabled = YES;
//    jielunLable.backgroundColor = [UIColor redColor];
    [self.view addSubview:jielunLable];
    [jielunLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_twoButton.mas_centerX);
        make.top.mas_equalTo(_twoButton.mas_bottom);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.8);
        make.height.height.mas_equalTo(jielunLable.mas_width);
    }];
    self.jielunImageView = [[UIImageView alloc] init];
    self.jielunImageView.image = [UIImage imageNamed:@"timg"];
    self.jielunImageView.backgroundColor = [UIColor yellowColor];
    self.jielunImageView.layer.cornerRadius = 120;
    self.jielunImageView.clipsToBounds = YES;
    [jielunLable addSubview:_jielunImageView];
    [_jielunImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(jielunLable.mas_centerX);
        make.centerY.mas_equalTo(jielunLable.mas_centerY);
        make.width.mas_equalTo(jielunLable.mas_width);
        make.height.mas_equalTo(jielunLable.mas_height);
        
    }];
}
- (void) createPageControll {
    self.pageController = [[UIPageControl alloc] init];
//    self.pageController.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.pageController];
    self.pageController.numberOfPages = 3;
    [self.pageController mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(_jielunImageView.mas_bottom);
        make.width.mas_equalTo(self.view.mas_width);
        make.height.mas_equalTo(self.view.mas_height).multipliedBy(0.08);
    }];
}
- (void) createSlider {
    self.mySlider = [[UISlider alloc] init];
    [self.view addSubview:self.mySlider];
    [self.mySlider setThumbImage:[UIImage imageNamed:@"player_slider_playback_thumb"] forState:UIControlStateNormal];
    [self.mySlider setMinimumTrackImage:[UIImage imageNamed:@"player_slider_playback_left"] forState:UIControlStateNormal];
    [self.mySlider mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(_pageController.mas_bottom);
        make.right.left.mas_equalTo(0);
    }];
}
- (void) createPlayButton {
    self.playButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.playButton setImage:[UIImage imageNamed:@"player_btn_play_normal"] forState:UIControlStateNormal];
    [self.view addSubview:self.playButton];
//    self.playButton.backgroundColor = [UIColor redColor];
    [self.playButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(_mySlider.mas_bottom);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.2);
        make.height.mas_equalTo(self.playButton.mas_width);
    }];
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftButton setImage:[UIImage imageNamed:@"player_btn_pre_normal"] forState:UIControlStateNormal];
    [self.view addSubview:leftButton];
    [leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.playButton.mas_centerY);
        make.trailing.mas_equalTo(self.playButton.mas_leading).mas_offset(-10);
        make.width.mas_equalTo(self.playButton.mas_width).multipliedBy(0.9);
        make.height.mas_equalTo(self.playButton.mas_height).multipliedBy(0.9);
    }];
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightButton setImage:[UIImage imageNamed:@"player_btn_next_normal"] forState:UIControlStateNormal];
    [self.view addSubview:rightButton];
    [rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.playButton.mas_centerY);
        make.leading.mas_equalTo(self.playButton.mas_trailing).mas_offset(10);
        make.width.mas_equalTo(self.playButton.mas_width).multipliedBy(0.9);
        make.height.mas_equalTo(self.playButton.mas_height).multipliedBy(0.9);
    }];

    
}
- (void) createBottomButton {
    self.downLoadButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.downLoadButton setImage:[UIImage imageNamed:@"player_btn_download_pay_normal"] forState:UIControlStateNormal];
    [self.view addSubview:self.downLoadButton];
    [self.downLoadButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(-10);
        make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.2);
        make.height.mas_equalTo(self.downLoadButton.mas_height);
        
    }];
    UIButton *cycleButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [cycleButton setImage:[UIImage imageNamed:@"player_btn_repeat_highlight"] forState:UIControlStateNormal];
    [self.view addSubview:cycleButton];
    [cycleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.downLoadButton.mas_centerY);
        make.trailing.mas_equalTo(self.downLoadButton.mas_leading).mas_offset(-5);
        make.width.mas_equalTo(self.downLoadButton.mas_width);
        make.height.mas_equalTo(self.downLoadButton.mas_height);
    }];
    
    UIButton *loveButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [loveButton setImage:[UIImage imageNamed:@"player_btn_favorited_normal"] forState:UIControlStateNormal];
    [self.view addSubview:loveButton];
    [loveButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.downLoadButton.mas_centerY);
        make.trailing.mas_equalTo(cycleButton.mas_leading).mas_offset(-2);
        make.width.mas_equalTo(cycleButton.mas_width);
        make.height.mas_equalTo(cycleButton.mas_height);
        
    }];
    UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [shareButton setImage:[UIImage imageNamed:@"player_btn_share_highlight"] forState:UIControlStateNormal];
    [self.view addSubview:shareButton];
   [ shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
       make.centerY.mas_equalTo(self.downLoadButton.mas_centerY);
       make.leading.mas_equalTo(self.downLoadButton.mas_trailing).mas_offset(5);
       make.width.mas_equalTo(self.downLoadButton.mas_width);
       make.height.mas_equalTo(self.downLoadButton.mas_height);
   }];
    UIButton *moreMusicButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [moreMusicButton setImage:[UIImage imageNamed:@"player_btn_playlist_highlight"] forState:UIControlStateNormal];
    [self.view addSubview:moreMusicButton];
    [moreMusicButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.downLoadButton.mas_centerY);
        make.leading.mas_equalTo(shareButton.mas_trailing).mas_offset(2);
        make.width.mas_equalTo(self.downLoadButton.mas_width);
        make.height.mas_equalTo(self.downLoadButton.mas_height);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
